//
// Copyright 2020, GeoSolutions Sas.
// All rights reserved.
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
//

@gn-page-max-width: 1440px;
@gn-hero-max-width: 716px;

@gn-main-color: #000000;
@gn-main-bg: #ffffff;
@gn-main-border-color: #dddddd;

@gn-main-variant-color: #000000;
@gn-main-variant-bg: #f2f0f0;

@gn-main-hover-color: #000000;
@gn-main-hover-bg: #eeeeee;

@gn-code-color: #000000;
@gn-code-bg: #eeeeee;

@gn-placeholder-color: #aaaaaa;
@gn-placeholder-bg: #dddddd;

@gn-disabled-color: #acacac;
@gn-disabled-bg: #fcfcfc;

@gn-primary: #397AAB;
@gn-info: #275a7f;
@gn-success: #58cf80;
@gn-warning: #ebbc35;
@gn-danger: #bb4940;

@gn-primary-contrast: #ffffff;
@gn-info-contrast: @gn-primary-contrast;
@gn-success-contrast: @gn-primary-contrast;
@gn-warning-contrast: @gn-primary-contrast;
@gn-danger-contrast: @gn-primary-contrast;

@gn-link-color: #397AAB;
@gn-link-hover-color: #1b4d74;

@gn-image-color: #333333;
@gn-image-bg: #f2f2f2;
@gn-editable-border: #dddddd;

@gn-jumbotron-color: #ffffff;
@gn-jumbotron-bg: #0c3756;

@gn-focus-color: rgba(#397AAB, 0.4);

@gn-footer-color: @gn-main-color;
@gn-footer-bg: @gn-main-bg;
@gn-footer-link-color: @gn-link-color;
@gn-footer-link-hover-color: @gn-link-hover-color;

@gn-badge-color: #000000;
@gn-badge-bg: #D5D5D5;

@gn-tray-bg: @gn-main-bg;
@gn-tray-color: lighten(@gn-main-color, 10%);
@gn-tray-border: lighten(@gn-primary, 10%);

@gn-font-family-serif: Georgia, 'Times New Roman', Times, serif;
@gn-font-family-monospace: Menlo, Monaco, Consolas, 'Courier New', monospace;
@gn-font-family-sans-serif: 'Montserrat', sans-serif;
@gn-font-family-base: 'Montserrat', sans-serif;

.gn-buttons-vars() {
    @button-default: {
        button-color: --gn-button-color, @gn-main-color;
        button-bg: --gn-button-bg, @gn-main-bg;
        button-action-border-color: --gn-button-action-border-color, @gn-main-border-color;
        button-border-color: --gn-button-border-color, @gn-main-bg;
        button-focus-color: --gn-button-focus-color, @gn-main-color;
        button-focus-bg: --gn-button-focus-bg, darken(@gn-main-bg, 10%);
        button-focus-border-color: --gn-button-focus-border-color, darken(@gn-main-bg, 10%);
        button-hover-color: --gn-button-hover-color, lighten(@gn-main-color, 10%);
        button-hover-bg: --gn-button-hover-bg, darken(@gn-main-bg, 10%);
        button-hover-border-color: --gn-button-hover-border-color, darken(@gn-main-bg, 10%);
        button-active-color: --gn-button-active-color, lighten(@gn-main-color, 10%);
        button-active-bg: --gn-button-active-bg, darken(@gn-main-bg, 10%);
        button-active-border-color: --gn-button-active-border-color, darken(@gn-main-bg, 10%);
        button-active-hover-color: --gn-button-active-hover-color, lighten(@gn-main-color, 10%);
        button-active-hover-bg: --gn-button-active-hover-bg, darken(@gn-main-bg, 17%);
        button-active-hover-border-color: --gn-button-active-hover-border-color, darken(@gn-main-bg, 17%);
        button-disabled-color: --gn-button-disabled-color, @gn-disabled-color;
        button-disabled-bg: --gn-button-disabled-bg, @gn-disabled-bg;
        button-disabled-border-color: --gn-button-disabled-border-color, @gn-disabled-bg;
        button-badge-color: --gn-button-badge-color, @gn-main-color;
        button-badge-bg: --gn-button-badge-bg, @gn-main-bg;
    }

    @button-primary: {
        button-color: --gn-button-primary-color, @gn-primary-contrast;
        button-bg: --gn-button-primary-bg, @gn-primary;
        button-border-color: --gn-button-primary-border-color, @gn-primary;
        button-focus-color: --gn-button-primary-focus-color, @gn-primary-contrast;
        button-focus-bg: --gn-button-primary-focus-bg, darken(@gn-primary, 10%);
        button-focus-border-color: --gn-button-primary-focus-border-color, darken(@gn-primary, 25%);
        button-hover-color: --gn-button-primary-hover-color, @gn-primary-contrast;
        button-hover-bg: --gn-button-primary-hover-bg, darken(@gn-primary, 10%);
        button-hover-border-color: --gn-button-primary-hover-border-color, darken(@gn-primary, 12%);
        button-active-color: --gn-button-primary-active-color, @gn-primary-contrast;
        button-active-bg: --gn-button-primary-active-bg, darken(@gn-primary, 10%);
        button-active-border-color: --gn-button-primary-active-border-color, darken(@gn-primary, 12%);
        button-active-hover-color: --gn-button-primary-active-hover-color, @gn-primary-contrast;
        button-active-hover-bg: --gn-button-primary-active-hover-bg, darken(@gn-primary, 17%);
        button-active-hover-border-color: --gn-button-primary-active-hover-border-color, darken(@gn-primary, 25%);
        button-disabled-color: --gn-button-primary-disabled-color, @gn-primary-contrast;
        button-disabled-bg: --gn-button-primary-disabled-bg, lighten(desaturate(@gn-primary, 30%), 20%);
        button-disabled-border-color: --gn-button-primary-disabled-border-color, lighten(desaturate(@gn-primary, 30%), 20%);
        button-badge-color: --gn-button-primary-badge-color, @gn-primary;
        button-badge-bg: --gn-button-primary-badge-bg, @gn-primary-contrast;
    }

    @button-info: {
        button-color: --gn-button-info-color, @gn-info-contrast;
        button-bg: --gn-button-info-bg, @gn-info;
        button-border-color: --gn-button-info-border-color, @gn-info;
        button-focus-color: --gn-button-info-focus-color, @gn-info-contrast;
        button-focus-bg: --gn-button-info-focus-bg, darken(@gn-info, 10%);
        button-focus-border-color: --gn-button-info-focus-border-color, darken(@gn-info, 25%);
        button-hover-color: --gn-button-info-hover-color, @gn-info-contrast;
        button-hover-bg: --gn-button-info-hover-bg, darken(@gn-info, 10%);
        button-hover-border-color: --gn-button-info-hover-border-color, darken(@gn-info, 12%);
        button-active-color: --gn-button-info-active-color, @gn-info-contrast;
        button-active-bg: --gn-button-info-active-bg, darken(@gn-info, 10%);
        button-active-border-color: --gn-button-info-active-border-color, darken(@gn-info, 12%);
        button-active-hover-color: --gn-button-info-active-hover-color, @gn-info-contrast;
        button-active-hover-bg: --gn-button-info-active-hover-bg, darken(@gn-info, 17%);
        button-active-hover-border-color: --gn-button-info-active-hover-border-color, darken(@gn-info, 25%);
        button-disabled-color: --gn-button-info-disabled-color, @gn-info-contrast;
        button-disabled-bg: --gn-button-info-disabled-bg, lighten(desaturate(@gn-info, 30%), 20%);
        button-disabled-border-color: --gn-button-info-disabled-border-color, lighten(desaturate(@gn-info, 30%), 20%);
        button-badge-color: --gn-button-info-badge-color, @gn-info;
        button-badge-bg: --gn-button-info-badge-bg, @gn-info-contrast;
    }

    @button-success: {
        button-color: --gn-button-success-color, @gn-success-contrast;
        button-bg: --gn-button-success-bg, @gn-success;
        button-border-color: --gn-button-success-border-color, @gn-success;
        button-focus-color: --gn-button-success-focus-color, @gn-success-contrast;
        button-focus-bg: --gn-button-success-focus-bg, darken(@gn-success, 10%);
        button-focus-border-color: --gn-button-success-focus-border-color, darken(@gn-success, 25%);
        button-hover-color: --gn-button-success-hover-color, @gn-success-contrast;
        button-hover-bg: --gn-button-success-hover-bg, darken(@gn-success, 10%);
        button-hover-border-color: --gn-button-success-hover-border-color, darken(@gn-success, 12%);
        button-active-color: --gn-button-success-active-color, @gn-success-contrast;
        button-active-bg: --gn-button-success-active-bg, darken(@gn-success, 10%);
        button-active-border-color: --gn-button-success-active-border-color, darken(@gn-success, 12%);
        button-active-hover-color: --gn-button-success-active-hover-color, @gn-success-contrast;
        button-active-hover-bg: --gn-button-success-active-hover-bg, darken(@gn-success, 17%);
        button-active-hover-border-color: --gn-button-success-active-hover-border-color, darken(@gn-success, 25%);
        button-disabled-color: --gn-button-success-disabled-color, @gn-success-contrast;
        button-disabled-bg: --gn-button-success-disabled-bg, lighten(desaturate(@gn-success, 30%), 20%);
        button-disabled-border-color: --gn-button-success-disabled-border-color, lighten(desaturate(@gn-success, 30%), 20%);
        button-badge-color: --gn-button-success-badge-color, @gn-success;
        button-badge-bg: --gn-button-success-badge-bg, @gn-success-contrast;
    }

    @button-warning: {
        button-color: --gn-button-warning-color, @gn-warning-contrast;
        button-bg: --gn-button-warning-bg, @gn-warning;
        button-border-color: --gn-button-warning-border-color, @gn-warning;
        button-focus-color: --gn-button-warning-focus-color, @gn-warning-contrast;
        button-focus-bg: --gn-button-warning-focus-bg, darken(@gn-warning, 10%);
        button-focus-border-color: --gn-button-warning-focus-border-color, darken(@gn-warning, 25%);
        button-hover-color: --gn-button-warning-hover-color, @gn-warning-contrast;
        button-hover-bg: --gn-button-warning-hover-bg, darken(@gn-warning, 10%);
        button-hover-border-color: --gn-button-warning-hover-border-color, darken(@gn-warning, 12%);
        button-active-color: --gn-button-warning-active-color, @gn-warning-contrast;
        button-active-bg: --gn-button-warning-active-bg, darken(@gn-warning, 10%);
        button-active-border-color: --gn-button-warning-active-border-color, darken(@gn-warning, 12%);
        button-active-hover-color: --gn-button-warning-active-hover-color, @gn-warning-contrast;
        button-active-hover-bg: --gn-button-warning-active-hover-bg, darken(@gn-warning, 17%);
        button-active-hover-border-color: --gn-button-warning-active-hover-border-color, darken(@gn-warning, 25%);
        button-disabled-color: --gn-button-warning-disabled-color, @gn-warning-contrast;
        button-disabled-bg: --gn-button-warning-disabled-bg, lighten(desaturate(@gn-warning, 30%), 20%);
        button-disabled-border-color: --gn-button-warning-disabled-border-color, lighten(desaturate(@gn-warning, 30%), 20%);
        button-badge-color: --gn-button-warning-badge-color, @gn-warning;
        button-badge-bg: --gn-button-warning-badge-bg, @gn-warning-contrast;
    }

    @button-danger: {
        button-color: --gn-button-danger-color, @gn-danger-contrast;
        button-bg: --gn-button-danger-bg, @gn-danger;
        button-border-color: --gn-button-danger-border-color, @gn-danger;
        button-focus-color: --gn-button-danger-focus-color, @gn-danger-contrast;
        button-focus-bg: --gn-button-danger-focus-bg, darken(@gn-danger, 10%);
        button-focus-border-color: --gn-button-danger-focus-border-color, darken(@gn-danger, 25%);
        button-hover-color: --gn-button-danger-hover-color, @gn-danger-contrast;
        button-hover-bg: --gn-button-danger-hover-bg, darken(@gn-danger, 10%);
        button-hover-border-color: --gn-button-danger-hover-border-color, darken(@gn-danger, 12%);
        button-active-color: --gn-button-danger-active-color, @gn-danger-contrast;
        button-active-bg: --gn-button-danger-active-bg, darken(@gn-danger, 10%);
        button-active-border-color: --gn-button-danger-active-border-color, darken(@gn-danger, 12%);
        button-active-hover-color: --gn-button-danger-active-hover-color, @gn-danger-contrast;
        button-active-hover-bg: --gn-button-danger-active-hover-bg, darken(@gn-danger, 17%);
        button-active-hover-border-color: --gn-button-danger-active-hover-border-color, darken(@gn-danger, 25%);
        button-disabled-color: --gn-button-danger-disabled-color, @gn-danger-contrast;
        button-disabled-bg: --gn-button-danger-disabled-bg, lighten(desaturate(@gn-danger, 30%), 20%);
        button-disabled-border-color: --gn-button-danger-disabled-border-color, lighten(desaturate(@gn-danger, 30%), 20%);
        button-badge-color: --gn-button-danger-badge-color, @gn-danger;
        button-badge-bg: --gn-button-danger-badge-bg, @gn-danger-contrast;
    }

    @button-tray: {
        button-color: --gn-button-tray-color, @gn-tray-color;
        button-bg: --gn-button-tray-bg, @gn-tray-bg;
        button-border-color: --gn-button-tray-border-color, darken(@gn-tray-border, 8%);
        button-focus-color: --gn-button-tray-focus-color, @gn-tray-color;
        button-focus-bg: --gn-button-tray-focus-bg, darken(@gn-tray-bg, 10%);
        button-focus-border-color: --gn-button-tray-focus-border-color, darken(@gn-tray-border, 25%);
        button-hover-color: --gn-button-tray-hover-color, @gn-tray-color;
        button-hover-bg: --gn-button-tray-hover-bg, darken(@gn-tray-bg, 10%);
        button-hover-border-color: --gn-button-tray-hover-border-color, darken(@gn-tray-border, 12%);
        button-active-color: --gn-button-tray-active-color, @gn-tray-color;
        button-active-bg: --gn-button-tray-active-bg, darken(@gn-tray-bg, 10%);
        button-active-border-color: --gn-button-tray-active-border-color, darken(@gn-tray-border, 12%);
        button-active-hover-color: --gn-button-tray-active-hover-color, @gn-tray-color;
        button-active-hover-bg: --gn-button-tray-active-hover-bg, darken(@gn-tray-bg, 17%);
        button-active-hover-border-color: --gn-button-tray-active-hover-border-color, darken(@gn-tray-border, 25%);
        button-disabled-color: --gn-button-tray-disabled-color, @gn-tray-color;
        button-disabled-bg: --gn-button-tray-disabled-bg, lighten(desaturate(@gn-tray-bg, 30%), 20%);
        button-disabled-border-color: --gn-button-tray-disabled-border-color, lighten(desaturate(@gn-tray-bg, 30%), 20%);
        button-badge-color: --gn-button-tray-badge-color, @gn-tray-bg;
        button-badge-bg: --gn-button-tray-badge-bg, @gn-tray-color;
    }
}

.gn-button-primary-vars(@variant: primary, @color, @contrast) {
    @result: {
        button-color: ~'--gn-button-@{variant}-color', @contrast;
        button-bg: ~'--gn-button-@{variant}-bg', @color;
        button-border-color: ~'--gn-button-@{variant}-border-color', @color;
        button-focus-color: ~'--gn-button-@{variant}-focus-color', @contrast;
        button-focus-bg: ~'--gn-button-@{variant}-focus-bg', darken(@color, 10%);
        button-focus-border-color: ~'--gn-button-@{variant}-focus-border-color', darken(@color, 25%);
        button-hover-color: ~'--gn-button-@{variant}-hover-color', @contrast;
        button-hover-bg: ~'--gn-button-@{variant}-hover-bg', darken(@color, 10%);
        button-hover-border-color: ~'--gn-button-@{variant}-hover-border-color', darken(@color, 12%);
        button-active-color: ~'--gn-button-@{variant}-active-color', @contrast;
        button-active-bg: ~'--gn-button-@{variant}-active-bg', darken(@color, 10%);
        button-active-border-color: ~'--gn-button-@{variant}-active-border-color', darken(@color, 12%);
        button-active-hover-color: ~'--gn-button-@{variant}-active-hover-color', @contrast;
        button-active-hover-bg: ~'--gn-button-@{variant}-active-hover-bg', darken(@color, 17%);
        button-active-hover-border-color: ~'--gn-button-@{variant}-active-hover-border-color', darken(@color, 25%);
        button-disabled-color: ~'--gn-button-@{variant}-disabled-color', @contrast;
        button-disabled-bg: ~'--gn-button-@{variant}-disabled-bg', @color;
        button-disabled-border-color: ~'--gn-button-@{variant}-disabled-border-color', @color;
        button-badge-color: ~'--gn-button-@{variant}-badge-color', @color;
        button-badge-bg: ~'--gn-button-@{variant}-badge-bg', @contrast;
    }
}

.gn-theme-vars() {

    @result: {
        font-family-sans-serif: --gn-font-family-sans-serif, @gn-font-family-sans-serif;
        font-family-serif: --gn-font-family-serif, @gn-font-family-serif;
        font-family-monospace: --gn-font-family-monospace, @gn-font-family-monospace;
        font-family-base: --gn-font-family-base, @gn-font-family-base;

        main-color: --gn-main-color, @gn-main-color;
        main-bg: --gn-main-bg, @gn-main-bg;
        main-border-color: --gn-main-border-color, @gn-main-border-color;

        main-variant-color: --gn-main-variant-color, @gn-main-variant-color;
        main-variant-bg: --gn-main-variant-bg, @gn-main-variant-bg;

        main-hover-color: --gn-main-hover-color, @gn-main-hover-color;
        main-hover-bg: --gn-main-hover-bg, @gn-main-hover-bg;

        placeholder-color: --gn-placeholder-color, @gn-placeholder-color;
        placeholder-bg: --gn-placeholder-bg, @gn-placeholder-bg;

        disabled-color: --gn-disabled-color, @gn-placeholder-color;
        disabled-bg: --gn-disabled-bg, @gn-placeholder-bg;

        primary: --gn-primary, @gn-primary;
        info: --gn-info, @gn-info;
        success: --gn-success, @gn-success;
        warning: --gn-warning, @gn-warning;
        danger: --gn-danger, @gn-danger;

        primary-contrast: --gn-primary-contrast, @gn-primary-contrast;
        info-contrast: --gn-info-contrast, @gn-info-contrast;
        success-contrast: --gn-success-contrast, @gn-success-contrast;
        warning-contrast: --gn-warning-contrast, @gn-warning-contrast;
        danger-contrast: --gn-danger-contrast, @gn-danger-contrast;

        link-color: --gn-link-color, @gn-link-color;
        link-hover-color: --gn-link-hover-color, @gn-link-hover-color;

        image-color: --gn-image-color, @gn-image-color;
        image-bg: --gn-image-bg, @gn-image-bg;

        focus-color: --gn-focus-color, @gn-focus-color;

        footer-color: --gn-footer-color, @gn-footer-color;
        footer-bg: --gn-footer-bg, @gn-footer-bg;
        footer-link-color: --gn-footer-link-color, @gn-footer-link-color;
        footer-link-hover-color: --gn-footer-link-hover-color, @gn-footer-link-hover-color;

        badge-color: --gn-badge-color, @gn-badge-color;
        badge-bg: --gn-badge-bg, @gn-badge-bg;

        loader-color: --gn-loader-color, @gn-main-color;
        loader-fade-color: --gn-loader-fade-color, rgba(@gn-main-color, 0.2);

        loader-primary-contrast-color: --gn-loader-primary-contrast-color, @gn-primary-contrast;
        loader-primary-contrast-fade-color: --gn-loader-primary-contrast-fade-color, rgba(@gn-primary-contrast, 0.2);

        loader-primary-color: --gn-loader-primary-color, @gn-primary;
        loader-primary-fade-color: --gn-loader-primary-fade-color, rgba(@gn-primary, 0.2);

        @button-default: .gn-buttons-vars()[@button-default];
        @button-primary: .gn-buttons-vars()[@button-primary];
        @button-info: .gn-buttons-vars()[@button-info];
        @button-success: .gn-buttons-vars()[@button-success];
        @button-warning: .gn-buttons-vars()[@button-warning];
        @button-danger: .gn-buttons-vars()[@button-danger];
        @button-tray: .gn-buttons-vars()[@button-tray];

        jumbotron-color: --gn-jumbotron-color, @gn-jumbotron-color;
        jumbotron-bg: --gn-jumbotron-bg, @gn-jumbotron-bg;

        timeline-selected-bg: --gn-timeline-selected-bg, rgba(@gn-primary, 0.05);
        timeline-histogram-bg: --gn-timeline-histogram-bg, rgba(@gn-primary, 0.5);
        timeline-histogram-border-color: --gn-timeline-histogram-color, darken(@gn-primary, 10%);
        timeline-range-bg: --gn-timeline-range-bg, rgba(@gn-main-color, 0.2);
        timeline-playback-range-bg: --gn-timeline-playback-range-bg, rgba(lighten(@gn-success, 10%), 0.2);

    }
}

@gn-theme-vars: .gn-theme-vars()[@result];
